<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla controllerform library
jimport('joomla.application.component.controllerform');
 
/**
 * Controller
 */
class MariagePlannerControllerBaseForm extends JControllerForm
{
	protected function allowEdit($data = array(), $key = 'id')
	{
		$model = $this->getModel();
		if($model->isOwner())
			return true;
		return parent::allowEdit($data, $key);
	}

	protected function allowAdd($data = array()) {
		return true;
		return parent::allowAdd($data);
	}
	
	public function save($key = null, $urlVar = null)
	{
		$app = JFactory::getApplication('site');
		$model = $this->getModel();
        
		$ids = $model->getOwnerItemIds();
	
		$app->setUserState("$this->option.edit.$this->context.id", $ids);
			
		$res = parent::save($key, $urlVar);

		$app->setUserState("$this->option.edit.$this->context.id", null);
		
		if(JRequest::getString('alt', 0, 'post')=='json') {
			$this->setRedirect(false);
			echo json_encode($res);
			return;
		}
		
		return $res;
	}
}
?>